package com.cola.demo.Soundsystem;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Grup:Soundsystem
 * @Auther:cola
 * @Data:2021/4/17-2021-04-16:41
 * @version:1.0
 */
//@Component
public class CompactDisc {
    private String title;
    private String artist;
    private Map<String,Music> tracks;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
        System.out.println("___在"+this.toString()+"注入Title");
    }

    public String getArtist() {
        return artist;
    }

    public void setArtist(String artist) {
        this.artist = artist;
        System.out.println("___在"+this.toString()+"注入Artist");
    }

    public Map<String, Music> getTracks() {
        return tracks;
    }

    public void setTracks(Map<String, Music> tracks) {
        this.tracks = tracks;
        System.out.println("___在"+this.toString()+"注入Tracks");
    }

    public CompactDisc() {
        super();
        System.out.println("Compactdisc无参构造"+toString());
    }

    public CompactDisc(String title, String artist) {
        this.title = title;
        this.artist = artist;
        System.out.println("Compactdisc有参构造"+toString());
    }

    public CompactDisc(String title, String artist, Map<String,Music> tracks) {
        this.title = title;
        this.artist = artist;
        this.tracks = tracks;
        System.out.println("Compactdisc有三个有参构造"+toString());
    }

    public void play(){
        System.out.println("正在播放音乐......."+toString()+":"+this.title+" by "+this.artist);
      /*  for (Music track:this.tracks) {
            System.out.println("音乐:"+track.getTitle()+",时长:"+track.getDuration());
        }*/

        for (String key:this.tracks.keySet()) {
            System.out.println("key:"+key);
            Music music =this.tracks.get(key);
            System.out.println("音乐:"+music.getTitle()+",时长:"+music.getDuration());
        }
    }
}
